package owl2vowl.parser.owlapi;

import owl2vowl.model.data.VowlData;
import owl2vowl.model.entities.nodes.classes.VowlClass;
import owl2vowl.model.entities.nodes.datatypes.VowlDatatype;
import owl2vowl.model.entities.properties.VowlDatatypeProperty;
import owl2vowl.model.entities.properties.VowlObjectProperty;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLDataProperty;
import org.semanticweb.owlapi.model.OWLDatatype;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLObjectVisitor;

public class EntityCreationVisitor implements OWLObjectVisitor {
	private VowlData vowlData;

	public EntityCreationVisitor(VowlData vowlData) {
		this.vowlData = vowlData;
	}

	public void visit(OWLClass ce) {
		if (!ce.isOWLThing() && !ce.isOWLNothing()) {
			if (!ce.isAnonymous()) {
				VowlClass clazz = new VowlClass(ce.getIRI());
				this.vowlData.addClass(clazz);
			}
		}
	}

	public void visit(OWLLiteral node) {
	}

	public void visit(OWLDatatype node) {
		if (!node.getIRI().toString().equals("http://www.w3.org/2000/01/rdf-schema#Literal")) {
			this.vowlData.addDatatype(new VowlDatatype(node.getIRI()));
		}
	}

	public void visit(OWLObjectProperty property) {
		if (!property.isAnonymous()) {
			VowlObjectProperty prop = new VowlObjectProperty(property.getIRI());
			this.vowlData.addObjectProperty(prop);
		}
	}

	public void visit(OWLDataProperty property) {
		if (!property.isAnonymous()) {
			VowlDatatypeProperty prop = new VowlDatatypeProperty(property.getIRI());
			this.vowlData.addDatatypeProperty(prop);
		}
	}
}